const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode: 'none',
    entry:  path.resolve(__dirname, './src/index.js'),
    output: {
        filename: '[name].js',
        // path: path.resolve(__dirname, 'dist'),
        library: 'nch123',
        libraryTarget:'umd', // 支持AMD CJS ESM script导入等
        libraryExport:'default',
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                use: 'babel-loader'
            },
            {
                test: /\.css$/,
                use: [
                  'style-loader',
                  'css-loader'
                ],
            },
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            //  title: 'Output Management',
            //  title: 'Development',
            template: path.resolve(__dirname, '/src/index.html'),
            chunks: ['main',]
          }),
        new webpack.HotModuleReplacementPlugin(),
    ],
    devServer: {
        contentBase: path.join(__dirname, 'src'),
        hot: true
        // compress: true,
        // port: 9000,
    },
    
}